<script language="javascript">
    $(document).ready(function(){
        $("#checkall").click(function(){
            var checked_status = this.checked;
            $('input[type="checkbox"]').each(function(){
               this.checked = checked_status;
            });
        });
    });
</script>
<script language="javascript">
    $(document).ready(function(){
        $("#checkall").click(function(){
            var checked_status = this.checked;
            $('input[type="checkbox"]').each(function(){
               this.checked = checked_status;
            });
        });
    });
</script>
<?php echo $this->Form->create('GiamGia',array('action'=>'admin_process')); ?>
<h1 align="center">CHƯƠNG TRÌNH GIẢM GIÁ</h1>
<?php
   // echo $this->Html->link('Thêm chương trình giảm giá', array('controller' => 'giam_gias', 'action' => 'add'), array('class' => 'lk'));
echo "<br /><br />";
?>
<table>
    <tr>
		<th><?php echo $this->Form->checkbox('all',array('id'=>'checkall')); ?></th>
        <th><?php echo $this->Paginator->sort('DOITUONGKH_ID', 'MÃ ĐỐI TƯỢNG'); ?></th>
        <th><?php echo $this->Paginator->sort('MUCGIAMGIA', 'MỨC GIẢM GIÁ'); ?></th>
        <th><?php echo $this->Paginator->sort('TGBD', 'THỜI GIAN BẮT ĐẦU'); ?></th>
        <th><?php echo $this->Paginator->sort('TGKT', 'THỜI GIAN KẾT THÚC'); ?></th>
        <th>THAY ĐỔI</th>
    </tr>

    <?php foreach ($giamgias as $giamgia): ?>
    <tr>
		<td><?php echo $this->Form->checkbox('GiamGia.id.'.$giamgia['GiamGia']['id']); ?></td>
        <td><?php echo $giamgia['GiamGia']['DOITUONGKH_ID']; ?></td>
        <td><?php echo $giamgia['GiamGia']['MUCGIAMGIA']; ?></td>
        <td><?php  echo date('d-m-Y', strtotime($giamgia['GiamGia']['TGBD'])); ?></td>
        <td><?php if ($giamgia['GiamGia']['TGKT'] != '0000-00-00')
                        echo date('d-m-Y', strtotime($giamgia['GiamGia']['TGKT']));
                    else echo '&nbsp';
            ?></td>
        <td><?php
            if ($this->Session->read('quyen') != 'nhanvien') {
                echo $this->Html->link($this->Html->image('/images/user_edit.png'), array('action' => 'edit', $giamgia['GiamGia']['id']), array('escape' => false));
            } else echo '&nbsp';?>
            <?php
            if ($this->Session->read('quyen') == 'quantri') {
                echo $this->Html->link($this->Html->image('/images/trash.png'), array('action' => 'delete', $giamgia['GiamGia']['id']),
                    array('confirm' => 'Bạn có chắc muốn xóa?', 'escape' => false));
} ?>
        </td>
    </tr>
    <?php endforeach; ?>
</table>

<?php
     echo $this->Form->end('Xóa các mục đã chọn', array('action' => 'Delete'));
?>

<div id="pagination">
    <div class="paging">
        <?php echo $this->Paginator->first('Trang đầu'); ?>
        <?php echo $this->Paginator->prev('<<' . __('Lùi', true),
        array(), null, array('class' => 'disabled')); ?>
        <?php echo $this->Paginator->numbers(); ?>
        <?php echo $this->Paginator->next(__('Tới', true) . '>>',
        array(), null, array('class' => 'disabled')); ?>
        <?php echo $this->Paginator->last('Trang cuối'); ?>
    </div>
</div>

<?php
echo $this->Html->link('Thêm chương trình giảm giá', array('controller' => 'giam_gias', 'action' => 'add'), array('class' => 'add'));
?>

<div id="Ltrangchu" align="center">
    <?php
    //echo $this->Html->link('TRANG CHỦ', array('controller' => ''));
    ?>
</div>
